from PyQt4 import QtGui,QtCore 
import sys 
import qt_ui.ui_main 
import qt_ui.ui_sql
import utils.database
import utils.dialogs
import FrmSQL

class FrmMain(QtGui.QMainWindow,qt_ui.ui_main.Ui_main):
    
        global mainWindow

        def populateTest(self):
            self.lineEdit.setText("172.30.1.1")
            self.spinBox.setValue(int("3306"))
            self.lineEdit_4.setText("infra")
            self.lineEdit_3.setText("root")
            self.lineEdit_2.setText("valecard")


        def __init__(self):
            QtGui.QMainWindow.__init__(self)
            self.setupUi(self)
            utils.dialogs.center(self)
            listaProvider = QtCore.QStringList()
            listaProvider.append("mySQL")
            listaProvider.append("Firebird")
            self.comboBox.addItems(listaProvider)
            QtCore.QObject.connect(self.buttonBox,QtCore.SIGNAL("accepted()"),self.connect)
            FrmMain.populateTest(self)
            mainWindow = self
    
        def connect(self):
            print self.comboBox.itemText(self.comboBox.currentIndex())
            utils.database.connect(str(self.comboBox.itemText(self.comboBox.currentIndex())),
            str(self.lineEdit.text()),
            str(self.spinBox.value()),
            str(self.lineEdit_4.text()),
            str(self.lineEdit_3.text()),
            str(self.lineEdit_2.text()))
            self.hide()
            sqlWindow = FrmSQL.FrmSQL(self)
            utils.dialogs.center(sqlWindow)